<template>
  <div class="interview-skill">
    <div class="top-box">
      <div class="nav-bar">
        <div class="nav-left">
          <i
            class="iconfont icon-zuojiantou"
            @click="$router.push('/find')"
          ></i>
        </div>
        <div class="nav-title">面试技巧</div>
      </div>
      <div class="search-box" @click="$router.push('/search')">
        <van-icon name="search" size="20" />
        请输入关键字
      </div>
    </div>
    <div class="skill-list">
      <div class="skill-item" @click="$router.push(`/skilldetail/${item.id}`)" v-for="item in skillList" :key="item.id">
        <div class="content">
          <div class="title">{{ item.title }}</div>
          <div class="info">
            <div class="time">{{ formatTime(item.created_at) }}</div>
            <div class="see">
              <van-icon name="eye-o" size="17px" /><span>{{ item.read }}</span>
            </div>
            <div class="zan">
              <van-icon
                name="good-job-o"
                size="17px"
                :class="{ active: item.star != 0 }"
              /><span>{{ item.star }}</span>
            </div>
          </div>
        </div>
        <div v-if="item.cover != null" class="cover">
          <img  :src="baseURL + item.cover" alt="" />
        </div>
      </div>
    </div>
    <div class="no-more">没有更多了</div>
  </div>
</template>

<script>
import { skillList } from '@/api/skill'

export default {
  data () {
    return {
      skillList: []
    }
  },
  methods: {
    async loadSkillList () {
      const res = await skillList()
      this.skillList = res.data.list
      console.log(this.skillList)
    },
    formatTime (date) {
      return this.dayjs(date).format('YYYY.MM.DD')
    }
  },
  created () {
    this.loadSkillList()
  }
}
</script>

<style lang="less" scoped>
.interview-skill {
  .top-box {
    padding-bottom: 10px;
    padding-top: 5px;
    .nav-bar {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      height: 40px;
      line-height: 1.5;
      text-align: center;
      background-color: #fff;
      .nav-left {
        position: absolute;
        top: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        padding: 0 10px;
        .iconfont {
          font-size: 25px;
        }
      }
      .nav-title {
        margin: 0 auto;
        font-size: 18px;
      }
    }
    .search-box {
      margin: 5px auto;
      width: 350px;
      height: 30px;
      color: #b3b3b3;
      border-radius: 20px;
      background-color: #f7f4f5;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 15px;
    }
  }
  .skill-list {
    padding: 0px 15px;
    .skill-item {
      display: flex;
      padding-bottom: 30px;
      font-size: 16px;
      .content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .title {
          text-align: left;
        }
        .info {
          color: #b4b4bd;
          font-size: 12px;
          display: flex;
          align-items: center;
          margin-top: 10px;
          span {
            margin-left: 8px;
          }
          .time {
            flex: 1;
            text-align: left;
          }
          .see {
            display: flex;
            align-items: center;
            margin-right: 25px;
          }
          .zan {
            display: flex;
            align-items: center;
            .active {
              color: red;
            }
          }
        }
      }
      .cover {
        width: 113px;
        height: 75px;
        margin-left: 20px;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
  .no-more {
    font-size: 14px;
    color: #a0a1a2;
    padding-bottom: 30px;
    padding-top: 10px;
  }
}
</style>
